package MyJunit;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class Test
{
	public static void main(String[] args) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException, InstantiationException, IOException
	{
		//读取配置文件
		Properties prop = new Properties();
		prop.load(new FileInputStream("./src/MyJunit/demo.properties"));
		//类名
		String className = prop.getProperty("className");
		//注解名
		String annotationName = prop.getProperty("annotationName");
		//通过反射解析类名方法
		Method[] ms = Class.forName(className).getDeclaredMethods();
		for(Method m : ms)
		{
			//若有目标注解则自动执行方法
			if(m.isAnnotationPresent((Class<MyTest>)Class.forName(annotationName)))
			{
				m.invoke(Class.forName(className).newInstance());
			}
		}
	}
}
